﻿using ConsoleStudy;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PicRec
{
    /// <summary>
    /// WinActive.xaml 的交互逻辑
    /// </summary>
    public partial class WinActive : MetroWindow
    {
        public WinActive()
        {
            InitializeComponent();
            tbMacCode.Text = FlyPC.GenerateMacCode();
            tbSecretKey.Focus();
        }

        private void btnActive_Click(object sender, RoutedEventArgs e)
        {
            FlyPC.GenerateActiveFile();
            string secretkey = tbSecretKey.Text.Trim();
            if (secretkey.Length == 0)
            {
                MessageBox.Show("请输入密钥后再激活","提示",MessageBoxButton.OK,MessageBoxImage.Information);
                return;
            }
            bool result = FlyPC.CheckSecretKey(secretkey);
            if (result)
            {
                MessageBox.Show("激活成功，请重新打开软件","激活成功",MessageBoxButton.OK,MessageBoxImage.Exclamation);
                this.Close();
            }
            else
            {
                MessageBox.Show("秘钥无效", "激活失败", MessageBoxButton.OK,MessageBoxImage.Error);
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
